import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/** note: submenu only apppear when children.length>=1
*   detail see  https://panjiachen.github.io/vue-element-admin-site/#/router-and-nav?id=sidebar
**/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
**/
export const constantRouterMap = [
  { path: '/login', component: _import('login/index'), hidden: true },
  { path: '/authredirect', component: _import('login/authredirect'), hidden: true },
  { path: '/404', component: _import('errorPage/404'), hidden: true },
  { path: '/401', component: _import('errorPage/401'), hidden: true },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [{
      path: 'dashboard',
      component: _import('dashboard/index'),
      name: 'dashboard',
      meta: { title: '窗e生', icon: 'dashboard', noCache: true }
    }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/index',
    meta: { title: '客户管理', icon: 'documentation', noCache: true },
    children: [{
      path: 'index',
      component: _import('user/index'),
      name: 'user',
      meta: { title: '客户管理', icon: 'documentation', noCache: true }
    },{
      path: 'userDtl',
      component: _import('user/userDtl'),
      name: 'user_dtl',
      hidden: true,
      meta: { title: '客户详情', icon: 'documentation', noCache: true }
    }
    ]
  },
  {
    path: '/order',
    component: Layout,
    meta: {
      title: '订单管理',
      icon: 'component'
    },
    children: [
      {
        path: '/online',
        component: _import('order/container'),
        redirct: '/order/online/index',
        meta: { title: '平台订单', icon: 'documentation', noCache: true },
        children: [{
          path: 'index',
          component: _import('order/index'),
          name: 'index',
          meta: { title: '所有订单', icon: 'documentation', noCache: true }
        },
        {
          path: 'handling',
          component: _import('order/handling'),
          name: 'handling',
          meta: { title: '处理中', icon: 'documentation', noCache: true }
        },
        {
          path: 'reback',
          component: _import('order/reback'),
          name: 'reback',
          meta: { title: '待回访', icon: 'documentation', noCache: true }
        },
        {
          path: 'order_cancel',
          component: _import('order/cancel'),
          name: 'cancel',
          meta: { title: '已取消', icon: 'documentation', noCache: true }
        },
        ]
      },
      {
        path: 'order_item',
        component: _import('order/item'),
        name: 'order_item',
        meta: { title: '订单详情', icon: 'documentation', noCache: true },
        hidden: true
      },
      {
        path: 'history',
        component: _import('order/history'),
        name: 'history',
        meta: { title: '线下订单', icon: 'documentation', noCache: true }
      },
      {
        path: 'import',
        component: _import('order/import'),
        name: 'import',
        meta: { title: '导入线下', icon: 'documentation', noCache: true },
        hidden: true
      }
    ]
  },
  {
    path: '/shop',
    component: Layout,
    redirect: '/shop/index',
    meta: {
      title: '店铺管理',
      icon: 'chart'
    },
    children: [{
      path: 'index',
      component: _import('shop/index'),
      name: 'shop',
      meta: { title: '店铺列表', icon: 'documentation', noCache: true }
    },{
      path: 'shop_waiting',
      component: _import('shop/waiting'),
      name: 'shop_waiting',
      meta: { title: '待审核列表', icon: 'documentation', noCache: true }
    },
    {
      path: 'add',
      component: _import('shop/add'),
      name: 'shop_add',
      meta: { title: '添加店铺', icon: 'documentation', noCache: true }
    },
    {
      path: 'edit',
      component: _import('shop/edit'),
      name: 'shop_edit',
      meta: { title: '编辑店铺', icon: 'documentation', noCache: true },
      hidden: true
    }
    ]
  },
  {
    path: '/balance',
    component: Layout,
    redirect: '/balance/balance_customer',
    meta: {
      title: '结算管理',
      icon: 'chart'
    },
    children: [{
      path: 'balance_customer',
      component: _import('balance/customer'),
      name: 'balance_customer',
      meta: { title: '客户结算', icon: 'documentation', noCache: true }
    },{
      path: 'balance_shop',
      component: _import('balance/shop'),
      name: 'balance_shop',
      meta: { title: '门店结算', icon: 'documentation', noCache: true }
    },{
      path: 'balance_shop_apply',
      component: _import('balance/shopApply'),
      name: 'balance_shop_apply',
      meta: { title: '提现申请', icon: 'documentation', noCache: true }
    }
    ]
  },
  {
    path: '/report',
    component: Layout,
    redirect: '/report/index',
    meta: {
      title: '报表管理',
      icon: 'chart'
    },
    children: [{
      path: 'index',
      component: _import('report/index'),
      name: 'report',
      meta: { title: '订单统计', icon: 'documentation', noCache: true }
    },{
      path: 'report_service',
      component: _import('report/service'),
      name: 'report_service',
      meta: { title: '服务统计', icon: 'documentation', noCache: true }
    }
    ]
  },
  {
    path: '/rule',
    component: Layout,
    redirect: '/rule/index',
    meta: {
      title: '规则管理',
      icon: 'chart'
    },
    children: [{
      path: 'set',
      component: _import('rule/set'),
      name: 'rule_set',
      meta: { title: '规则配置', icon: 'documentation', noCache: true }
    },
    {
      path: 'index',
      component: _import('rule/index'),
      name: 'rule_index',
      meta: { title: '规则列表', icon: 'documentation', noCache: true }
    },
    {
      path: 'client',
      component: _import('rule/client'),
      name: 'rule_client_protocol',
      meta: { title: '客户端协议', icon: 'documentation', noCache: true }
    },
    {
      path: 'shop',
      component: _import('rule/shop'),
      name: 'rule_shop_client_protocol',
      meta: { title: '门店协议', icon: 'documentation', noCache: true }
    },
    ]
  },
  {
    path: '/sys',
    component: Layout,
    redirect: '/sys/index',
    meta: {
      title: '系统管理',
      icon: 'chart'
    },
    children: [{
      path: 'index',
      component: _import('staff/index'),
      name: 'staff_user',
      meta: { title: '用户管理', icon: 'documentation', noCache: true }
    },{
      path: 'agent',
      component: _import('agent/index'),
      name: 'agent_index',
      meta: { title: '代理商管理', icon: 'documentation', noCache: true }
    }
    ]
  },
  { path: '/searchBySdk', component: _import('common/searchBySdk'), hidden: true },

  

  // {
  //   path: '/address',
  //   component: Layout,
  //   redirect: '/address/index',
  //   meta: {
  //     title: '地区管理',
  //     icon: 'component'
  //   },
  //   children: [{
  //     path: 'index',
  //     component: _import('user/index'),
  //     name: 'address',
  //     meta: { title: '地区管理', icon: 'documentation', noCache: true }
  //   }]
  // }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  { path: '*', redirect: '/404', hidden: true }
]
